﻿using Dapper;
using ZingBlog.Domain.IRepository;
using ZingBlog.Domain.Entities;
using System.Collections.Generic;
using ZingFrameworkCore.Data;
namespace ZingBlog.Repository
{
    public class DiarysRepository : BaseRepository<DiarysEntity>, IDiarysRepository
    {
        public IEnumerable<DiarysEntity> GetYear()
        {
            using (var conn = MySqlHelper.GetConnection())
            {
                var sql = @"SELECT date_format(CreateOn,'%Y') as Year FROM t_diarys
                            GROUP BY date_format(CreateOn,'%Y')
                            ORDER BY date_format(CreateOn,'%Y') desc";
                return conn.Query<DiarysEntity>(sql);
            }
        }
    }
}
